#! /bin/bash
#SQOOP_HOME=/opt/cloudera/parcels/CDH-6.2.1-1.cdh6.2.1.p0.1425774/bin/sqoop
SQOOP_HOME=/usr/bin/sqoop
if [[ $1 == "" ]];then
   TD_DATE=`date -d '1 days ago' "+%Y-%m-%d"`
else
   TD_DATE=$1
fi

echo '========================================'
echo '==============开始全量导入==============='
echo '========================================'
-- 一、nev
# 1.web_chat_ems_2019_07:访问与咨询信息主表
# Mysql-OLAP: 106.75.33.59:3306  username: itcast_edu_stu   password: itcast_edu_stu

/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/nev?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select * from web_chat_ems_2019_07 where 1=1 and  \$CONDITIONS" \
--hcatalog-database zxedu_ods \
--hcatalog-table web_chat_ems_2019_07 \
-m 1

# 2.访问与咨询信息副表：web_chat_text_ems_2019_07
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/nev?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select * from web_chat_text_ems_2019_07 where 1=1 and  \$CONDITIONS" \
--hcatalog-database zxedu_ods \
--hcatalog-table web_chat_text_ems_2019_07 \
-m 1


# 二、scrm
# 1.customer_relationship:客户意向表
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select * from customer_relationship where 1=1 and  \$CONDITIONS" \
--hcatalog-database zxedu_ods \
--hcatalog-table customer_relationship \
-m 1


# 2.customer_clue:客户线索表
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select * from customer_clue where 1=1 and  \$CONDITIONS" \
--hcatalog-database zxedu_ods \
--hcatalog-table customer_clue \
-m 1

# 3.customer_appeal:线索申诉表
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select * from customer_appeal where 1=1 and  \$CONDITIONS" \
--hcatalog-database zxedu_ods \
--hcatalog-table customer_appeal \
-m 1

# 4.customer:客户静态信息表
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select * from customer where 1=1 and  \$CONDITIONS" \
--hcatalog-database zxedu_ods \
--hcatalog-table customer \
-m 1

# 5.itcast_school:校区表
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select * from itcast_school where 1=1 and  \$CONDITIONS" \
--hcatalog-database zxedu_ods \
--hcatalog-table itcast_school \
-m 1

# 6、itcast_subject：学科表
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select * from itcast_subject where 1=1 and  \$CONDITIONS" \
--hcatalog-database zxedu_ods \
--hcatalog-table itcast_subject \
-m 1

# 7.employee：员工信息表
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select * from employee where 1=1 and  \$CONDITIONS" \
--hcatalog-database zxedu_ods \
--hcatalog-table employee \
-m 1

# 8.scrm_department:员工部门表
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select * from scrm_department where 1=1 and  \$CONDITIONS" \
--hcatalog-database zxedu_ods \
--hcatalog-table scrm_department \
-m 1

# 9.itcast_clazz：班级信息表
/usr/bin/sqoop import "-Dorg.apache.sqoop.splitter.allow_text_splitter=true" \
--connect 'jdbc:mysql://106.75.33.59:3306/scrm?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true' \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query "select * from itcast_clazz where 1=1 and  \$CONDITIONS" \
--hcatalog-database zxedu_ods \
--hcatalog-table itcast_clazz \
-m 1